package com.lagou.web.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.dubbo.rpc.RpcContext;
import com.lagou.service.HelloService;
import com.lagou.service.HiService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * @author ascetic
 * @version 1.0
 * @ClassName HelloController
 * @Description TODO
 * @date 2020-07-13 13:32
 */
@Controller
@RequestMapping("/")
@ResponseBody
public class HelloController {

    @Reference
    private HiService hiService;

    @Reference
    private HelloService helloService;


    @RequestMapping("hello")
    public String hello(String name, HttpServletRequest request){

//        RpcContext.getContext().setAttachment("requestIP", request.getRemoteAddr());

        String hello = helloService.sayHello(name,0);
        String hi = hiService.sayHello(name,0);

        return hello + "|" + hi;

    }
}